﻿Imports Abyx.SVCMS.Library
Imports Abyx.SVCMS.Library.DB
Imports Abyx.WindowsExtendedControls

Public Class SEC_Login_Form

    Private Sub OK_ImageButton_Click(sender As System.Object, e As System.EventArgs) Handles OK_ImageButton.Click

        Try
            Dim user As UserType = SecManager.Login(UsernameTextBox.Text, PasswordTextBox.Text)
            If user IsNot Nothing Then
                AppSettings.LoggedUser = user
                AppSettings.MainForm = SVCM_Form
                SVCM_Form.Show()
                Me.Close()
            Else
                AMsg.ShowDialog(AppConstants.Error_Message_Login_Failure, MsgBoxStyle.Critical)
            End If
        Catch ex As DataValidationException
            AMsg.ShowDialog(ex.Message, MsgBoxStyle.Critical)
        Catch ex As Exception
            AMsg.ShowDialog("Error: " & vbNewLine & ex.ToString, MsgBoxStyle.Critical)
        End Try

    End Sub

    Private Sub Cancel_ImageButton_Click(sender As System.Object, e As System.EventArgs) Handles Cancel_ImageButton.Click
        Me.Close()
    End Sub


End Class
